@extends('backend::common.common_right')
@section('content')
<style>
    .upload_file {border:1px solid #eee; position: absolute;left: 0;width: 100%;height: 100%;top: 0;opacity: 0;z-index: 2;cursor: pointer;}
    .show_img{border:1px solid #eee;width:100%;height: 100%;}
    .fa-trash-o{position: absolute;right: 5px;top: 5px;color: red;width: 15px;height: 15px;z-index: 3}
    .layui-layer-move{z-index: 0}
</style>
<div class="col-sm-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>施工图编辑</h5>
            <div class="ibox-tools">

                <a type="button" class="close" href="{{url('backend/model',['type'=>$type])}}"> <span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form class="form-horizontal m-t"  action="{{url('backend/modeledit')}}" method="post"  onsubmit="return check()">
                {{ csrf_field() }}
                <input type="hidden" name="id" value="{{$model->id or ''}}">
                <input type="hidden" name="user_id" value="{{$model->user_id or ''}}">
                <input type="hidden" name="type" value="{{$type}}">
                <input type="hidden" name="filesize" value="{{$model->filesize}}">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">模型名称：</label>
                        <div class="col-sm-8">
                            <input type="text" name="title" value="{{$model->title}}" class="form-control" placeholder="请输入模型名称">
                        </div>
                    </div>
                    <div class="form-group " id="aetherupload-wrapper" ><!--组件最外部需要有一个名为aetherupload-wrapper的id，用以包装组件-->
                        <label class="col-sm-2 control-label">模型文件：</label>
                        <div class="col-sm-8">
                            <input type="file" id="file" onchange="aetherupload(this,'model').success(someCallback).upload()"/><!--需要有一个名为file的id，用以标识上传的文件，aetherupload(file,group)中第二个参数为分组名，success方法可用于声名上传成功后的回调方法名-->
                            <div class="progress " style="height: 6px;margin-bottom: 2px;margin-top: 10px;width: 200px;">
                                <div id="progressbar" style="background:blue;height:6px;width:0;"></div><!--进度条-->
                            </div>
                            <span style="font-size:12px;color:#aaa;" id="output"></span><!--提示信息-->
                            <input type="hidden" name="file" value="{{$model->file}}" id="savedpath" ><!--需要有一个名为savedpath的id，保存路径的表单字段，还需要一个任意名称的name-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">封面：</label>
                        <div class="col-sm-9">
                            <div class="col-sm-2" id="aetherupload-wrapper" style="height: 100px;position: relative;padding:0;">
                                <img class="show_img" src="{{env('APP_IMGSMAllURL')}}{{$model->image or 'images/default.png'}}"  alt="">
                                <input id="file" class="upload_file" onchange="aetherupload(this,'image').success(someoneCallback).upload()" type="file" val=""/>
                                <input type="hidden" name="image" id="savedpath" value="{{$model->image or ''}}">
                                <span style="font-size:12px;color:#aaa;"  id="output"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" >
                        <a class="btn btn-primary" onclick="showImgs({{$model->id}})" href="javascript:;">查看原图</a>
                        <label class="col-sm-2 control-label">渲染图：</label>
                        <div class="col-sm-9">
                            @for ($i = 1; $i <= 5; $i++)
                                <div id="aetherupload-wrapper" class="col-sm-2" style="height: 100px;position: relative;padding:0;">
                                    @if($i >1 ) <a href="javascript:;" onclick="delImg(this)"><i class="fa fa-trash-o"  aria-hidden="true"></i></a> @endif
                                    <img class="show_img" src="{{env('APP_IMGSMAllURL')}}{{$model->images_thumb[$i-1] or 'images/default.png'}}"  alt="">
                                    <input id="file" class="upload_file" onchange="aetherupload(this,'image').success(someCallback).upload()" type="file" val=""/>
                                    <input type="hidden" name="images{{$i}}" id="savedpath" value="{{$model->images[$i-1] or ''}}">
                                    <input type="hidden" name="image{{$i}}" id="savedpaththumb" value="{{$model->images_thumb[$i-1] or ''}}">
                                    <span style="font-size:12px;color:#aaa;" id="output"></span>
                                </div>
                            @endfor
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">CAD版本：</label>
                        <div class="col-sm-8">
                            <select class="form-control" name="appversion">
                                <option>2000</option>
                                <option>2001</option>
                                <option>2002</option>
                                <option>2003</option>
                                <option>2004</option>
                                <option>2005</option>
                                <option>2006</option>
                                <option>2007</option>
                                <option>2008</option>
                                <option>2009</option>
                                <option>2010</option>
                                <option>2011</option>
                                <option>2012</option>
                                <option>2013</option>
                                <option>2014</option>
                                <option>2015</option>
                                <option>2016</option>
                                <option>2017</option>
                                <option>2018</option>
                                <option>2019</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">分类：</label>
                        <div class="col-sm-8">
                            <div class="col-sm-6 row">
                                <select class="form-control catsshow" name="cat_id1">
                                    @foreach($cats[$type] as $ca)
                                        <option value="{{$ca->id}}" @if($model->cat_id1 == $ca->id) selected @endif>{{$ca->catname}}</option>
                                    @endforeach
                                </select>
                            </div>
                            @foreach($cats[$type] as $c)
                                <div class="col-sm-6 row catrow cats2show{{$c->id}}" @if($model->cat_id1 == $c->id) @else style="display:none" @endif >
                                    <select class="form-control" name="cat_id2" onchange="changeCatid(this.value)">
                                        @foreach($cats[$c->id] as $ca2)
                                            <option  value="{{$ca2->id}}">{{$ca2->catname}}</option>
                                        @endforeach
                                    </select>
                                </div>
                            @endforeach
                        </div>

                    </div>
                    <div class="form-group{{ $errors->has('coins') ? ' has-error' : '' }}">
                        <label class="col-sm-2 control-label">价格：</label>
                        <div class="col-sm-2">
                            <input type="number" name="coins" value="" class="form-control" >
                            @if ($errors->has('coins'))
                                <span class="help-block">
                                        <strong>{{ $errors->first('coins') }}</strong>
                                    </span>
                            @endif
                        </div>
                        <label class="control-label">交易币</label>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">VIP免费：</label>
                        <div class="col-sm-8">
                            <select class="form-control" name="is_vip">
                                <option value="0" selected>否</option>
                                <option value="1" @if($model->is_vip == $ca2->id) selected @endif>是</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">审核状态：</label>
                        <div class="col-sm-8">
                            <select class="form-control" name="status">
                                <option value="0" selected>待审核</option>
                                <option value="1" @if($model->status == 1) selected @endif>通过</option>
                                <option value="2" @if($model->status == 2) selected @endif>不通过</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">备注：</label>
                    <div class="col-sm-8">
                        <textarea name="note" id="" cols="32" rows="5">{{$model->note}}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-3">
                        <button class="btn btn-primary" type="submit">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $("select[name='appversion']").val('{{$model->appversion}}')
    $("select[name='cat_id2']").val('{{$model->cat_id2}}')
</script>
<script src="{{ URL::asset('admin/js/common_model.js') }}"></script>
@endsection